package com.yzcs.tvapp.simple.fragment

import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.cxy.common.request.NetDialog
import com.fy.baselibrary.base.fragment.BaseFragment
import com.fy.baselibrary.utils.notify.L
import com.fy.baselibrary.utils.notify.S
import com.yzcs.tvapp.R
import com.yzcs.tvapp.databinding.SimpleFragmentLayoutBinding
import com.yzcs.tvapp.simple.activity.RecommendVideoViewModel
import com.yzcs.tvapp.simple.activity.VideoBean

/**
 * description mvvm 在 fragment 中的使用
 * Created by fangs on 2021/9/17 15:08.
 */
class SimpleFragment : BaseFragment<RecommendVideoViewModel, SimpleFragmentLayoutBinding>() {

    lateinit var videoBean: VideoBean
    override fun setContentLayout(): Int {
        return R.layout.simple_fragment_layout
    }

    override fun initData(
        viewModel: RecommendVideoViewModel?,
        dataBinding: SimpleFragmentLayoutBinding?,
        savedInstanceState: Bundle?
    ) {

        videoBean = arguments?.getSerializable("videoBean") as VideoBean
        vdb.videoBean = videoBean
        vdb.onClickListener = this

        initRv()
    }

    var num = 1
    override fun onClick(view: View) {
        when (view.id) {
            R.id.imgVideoCover -> {
                videoBean.title = "大王叫我来巡山"
                num++

            }
        }
    }

    fun initRv() {
        vdb.rvDemo.layoutManager = LinearLayoutManager(context)

//        vm.getListData(context!!, NetDialog().init(this, R.string.loading))
//            .observe(this,
//                Observer<List<TestBean>> {
//                    L.e("")
//                })
    }
}